package org.study;

public class ThreadYieldDemo {


    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            while (true) {
                System.out.println("thread1");
                Thread.yield();
            }
        });
        Thread thread2 = new Thread(() -> {
            while (true) {
                System.out.println("thread2");
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        thread.start();
        thread2.start();


    }
}
